/*
 Navicat Premium Data Transfer

 Source Server         : 虚拟机oracle
 Source Server Type    : Oracle
 Source Server Version : 110200
 Source Host           : 192.168.199.183:1521
 Source Schema         : SYSTEM

 Target Server Type    : Oracle
 Target Server Version : 110200
 File Encoding         : 65001

 Date: 04/12/2021 15:21:20
*/


-- ----------------------------
-- Table structure for T_BORROW
-- ----------------------------
DROP TABLE "SYSTEM"."T_BORROW";
CREATE TABLE "SYSTEM"."T_BORROW" (
  "BORROWID" NUMBER NOT NULL,
  "USERID" NUMBER NOT NULL,
  "BOOKID" NUMBER NOT NULL,
  "BORROWTIME" DATE NOT NULL,
  "RETURNTIME" DATE
)
LOGGING
NOCOMPRESS
PCTFREE 10
INITRANS 1
STORAGE (
  INITIAL 65536 
  NEXT 1048576 
  MINEXTENTS 1
  MAXEXTENTS 2147483645
  FREELISTS 1
  FREELIST GROUPS 1
  BUFFER_POOL DEFAULT
)
PARALLEL 1
NOCACHE
DISABLE ROW MOVEMENT
;

-- ----------------------------
-- Records of T_BORROW
-- ----------------------------
INSERT INTO "SYSTEM"."T_BORROW" VALUES ('26', '11', '2', TO_DATE('2021-11-18 00:00:00', 'SYYYY-MM-DD HH24:MI:SS'), TO_DATE('2021-11-18 00:00:00', 'SYYYY-MM-DD HH24:MI:SS'));
INSERT INTO "SYSTEM"."T_BORROW" VALUES ('27', '11', '1', TO_DATE('2021-11-18 00:00:00', 'SYYYY-MM-DD HH24:MI:SS'), TO_DATE('2021-11-18 00:00:00', 'SYYYY-MM-DD HH24:MI:SS'));
INSERT INTO "SYSTEM"."T_BORROW" VALUES ('28', '11', '4', TO_DATE('2021-11-18 00:00:00', 'SYYYY-MM-DD HH24:MI:SS'), TO_DATE('2021-11-18 00:00:00', 'SYYYY-MM-DD HH24:MI:SS'));
INSERT INTO "SYSTEM"."T_BORROW" VALUES ('30', '14', '2', TO_DATE('2021-11-18 00:00:00', 'SYYYY-MM-DD HH24:MI:SS'), TO_DATE('2021-11-19 00:00:00', 'SYYYY-MM-DD HH24:MI:SS'));
INSERT INTO "SYSTEM"."T_BORROW" VALUES ('32', '14', '4', TO_DATE('2021-11-18 00:00:00', 'SYYYY-MM-DD HH24:MI:SS'), TO_DATE('2021-11-18 00:00:00', 'SYYYY-MM-DD HH24:MI:SS'));
INSERT INTO "SYSTEM"."T_BORROW" VALUES ('38', '14', '1', TO_DATE('2021-11-19 00:00:00', 'SYYYY-MM-DD HH24:MI:SS'), TO_DATE('2021-11-19 00:00:00', 'SYYYY-MM-DD HH24:MI:SS'));
INSERT INTO "SYSTEM"."T_BORROW" VALUES ('39', '14', '1', TO_DATE('2021-11-19 00:00:00', 'SYYYY-MM-DD HH24:MI:SS'), TO_DATE('2021-11-19 00:00:00', 'SYYYY-MM-DD HH24:MI:SS'));
INSERT INTO "SYSTEM"."T_BORROW" VALUES ('40', '14', '1', TO_DATE('2021-11-19 00:00:00', 'SYYYY-MM-DD HH24:MI:SS'), TO_DATE('2021-11-19 00:00:00', 'SYYYY-MM-DD HH24:MI:SS'));
INSERT INTO "SYSTEM"."T_BORROW" VALUES ('101', '14', '2', TO_DATE('2021-12-04 15:00:00', 'SYYYY-MM-DD HH24:MI:SS'), TO_DATE('2021-12-04 15:00:06', 'SYYYY-MM-DD HH24:MI:SS'));

-- ----------------------------
-- Primary Key structure for table T_BORROW
-- ----------------------------
ALTER TABLE "SYSTEM"."T_BORROW" ADD CONSTRAINT "SYS_C0011127" PRIMARY KEY ("BORROWID");

-- ----------------------------
-- Checks structure for table T_BORROW
-- ----------------------------
ALTER TABLE "SYSTEM"."T_BORROW" ADD CONSTRAINT "SYS_C0011122" CHECK ("BORROWID" IS NOT NULL) NOT DEFERRABLE INITIALLY IMMEDIATE NORELY VALIDATE;
ALTER TABLE "SYSTEM"."T_BORROW" ADD CONSTRAINT "SYS_C0011123" CHECK ("USERID" IS NOT NULL) NOT DEFERRABLE INITIALLY IMMEDIATE NORELY VALIDATE;
ALTER TABLE "SYSTEM"."T_BORROW" ADD CONSTRAINT "SYS_C0011124" CHECK ("BOOKID" IS NOT NULL) NOT DEFERRABLE INITIALLY IMMEDIATE NORELY VALIDATE;
ALTER TABLE "SYSTEM"."T_BORROW" ADD CONSTRAINT "SYS_C0011125" CHECK ("BORROWTIME" IS NOT NULL) NOT DEFERRABLE INITIALLY IMMEDIATE NORELY VALIDATE;

-- ----------------------------
-- Triggers structure for table T_BORROW
-- ----------------------------
CREATE TRIGGER "SYSTEM"."t_borrow_trig" BEFORE INSERT ON "SYSTEM"."T_BORROW" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW 
declare
begin
    select seq_t_borrow.nextval into :new.borrowid from dual;
end dept_trig;
/
